<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@include file="/include/tagLib.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!doctype html>
<html lang="en">
<head>
    <title>${sieName}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <%@include file="/include/cssLib.jsp" %>
</head>

<body>
<div class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <!-- 菜单 -->
            <tag:nav key="searchStat"/>

            <div class="tab-content">
                <div class="tab-pane active">
                    <div class="col-md-10 col-md-offset-1">
                        <div class="card">
                            <div class="card-header">
                                <form id="searchForm" action="${ctx}/adminConsole/searchHi/stat" method="post" class="hide">
                                    <div class="col-md-1">
                                        <button type="submit" class="btn btn-twitter"><i class="fa fa-search"></i></button>
                                        <input type="hidden" id="pageNo" name="pageNo"/>
                                        <input type="hidden" id="pageSize" name="pageSize" />
                                    </div>
                                </form>
                                <tag:paging-simple page="${pageResult}"/>
                                <div class="input-group col-md-6 hide">
                                    <div class="form-group label-floating is-empty">
                                        &nbsp;&nbsp;
                                        <button id="optimizeKeyword" class="btn btn-success">优化关键词</button>
                                    </div>
                                </div>
                            </div>
                            <div class="card-content">
                                    <div class="table-responsive">
                                        <table class="table table-bordered table-hover">
                                            <thead>
                                            <tr>
                                                <th class="text-center hide">勾选关键词</th>
                                                <th width="100">搜索次数</th>
                                                <th>关键词</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                                <c:forEach items="${pageResult.result }" var="data" varStatus="vStatus">
                                                    <tr>
                                                        <td class="text-center hide">
                                                            <div class="checkbox" style="width: auto;">
                                                                <label class="w_100">
                                                                    <input type="checkbox" name="checkItem" value="${data.text}">
                                                                </label>
                                                            </div>
                                                        </td>
                                                        <td class="text-center">${data.num}</td>
                                                        <td>${data.text}</td>
                                                    </tr>
                                                </c:forEach>
                                            </tbody>
                                        </table>
                                    </div>
                                    <tag:paging page="${pageResult}"/>
                                </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<%@include file="/include/sidebarRight.jsp" %>
</body>
<%@include file="/include/scriptLib.jsp" %>

<script type="text/javascript">
    $(document).ready(function() {
        //绑定 重新爬取
        bindBtnBatchOperRowsByCustomConfirm("optimizeKeyword", "checkItem", function (selectVals) {
            swal({
                title: '您确定要优化勾选的关键词？',
                input: 'select',
                inputOptions: {
                    'all': '所有模块',
                    'qa': '问答库',
                },
                inputPlaceholder: '请选择对应优化模块',
                showCancelButton: true,
                inputValidator: function (value) {
                    return new Promise(function (resolve, reject) {
                        if (value === "") {
                            reject("请选择对应优化模块");
                        }else {
                            resolve()
                        }
                    })
                }
            }).then(function (module) {
                HttpUtil.ajaxAsyncJsonPost("/adminConsole/searchHi/optimizeKeyword", {selectVals: selectVals, module: module}, function(message){
                    dialogTip(message);
                    refreshPage(2000);
                });
            });
        });

        //绑定 全选
//        bindCheckBoxSelectAll("checkAll", "checkItem");

    });
</script>
</html>